#ifndef CONFIG_H
#define CONFIG_H

#include <QWidget>
#include <QSerialPort>
#include <QSerialPortInfo>
#include <setconf_success.h>
#include <QSettings>
#include <QFileDialog>
#include <QTcpSocket>
#include <QHostAddress>
#include <QMessageBox>
#include <QUdpSocket>
#include <QDebug>

//定义全局变量
extern QSerialPort *serial;
extern QSerialPort *serial_send;

extern QString filepath;

struct network_confdef{
    QString rcv_tcp_ip;
    QString rcv_tcp_port;
    QString send_tcp_ip;
    QString send_tcp_port;
    QString send_udp_ip;
    QString send_udp_port;
};
extern network_confdef netconf;


namespace Ui {
class Config;
}

class Config : public QWidget
{
    Q_OBJECT

public:
    explicit Config(QWidget *parent = nullptr);
    void serialmapinit(void);
    ~Config();

    void dealMsg();

private slots:
    void on_detemineButton_clicked();

    void on_pingsever_clicked();

    //bool eventFilter(QObject *target, QEvent *event);

    //void on_pingclient_clicked();

private:
    Ui::Config *ui;

    //网口定义
    QTcpSocket *socket;

    //UDP定义
    QUdpSocket *udpSocket;

    //定义串口配置映射表
    QMap<QString, QSerialPort::BaudRate> baudrateMap;
    QMap<QString, QSerialPort::StopBits> stopbitMap;
    QMap<QString, QSerialPort::DataBits> databitMap;
    QMap<QString, QSerialPort::Parity> parityMap;
};

#endif // CONFIG_H
